]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
barLevel: Don't show border radius if the value is 0
authorverdre <verdre@v0yd.nl>
Sat, 2 Feb 2019 16:01:29 +0000 (17:01 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 17 Apr 2019 18:38:13 +0000 (18:38 +0000)
Work around a known regression from [1] that caused the volume bar in
the OSD window to never be hidden, even if the volume is set to 0. This
happened because the border radius of the barLevel is always drawn
without ensuring that the actual bar is visible.

So simply check if the value to draw is 0, and if it is, don't draw the
border radius of the bar at all. This will still result in incorrect
representation of values that have a width smaller than 2*border-radius,
but at least the bar looks right for a width of 0 now.

[1] https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/2

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/384

js/ui/barLevel.js

index d8d37369df6aeb860264d64bc119ec1db6eb2afa..c4072e2cf83338e69798ba92a519e51bb95dbd75 100644 (file)
@@ -121,7 +121,8 @@ var BarLevel = class {
         cr.lineTo(x, (height - barLevelHeight) / 2);
         cr.lineTo(x, (height + barLevelHeight) / 2);
         cr.lineTo(barLevelBorderRadius + barLevelBorderWidth, (height + barLevelHeight) / 2);
-        Clutter.cairo_set_source_color(cr, barLevelActiveColor);
+        if (this._value > 0)
+          Clutter.cairo_set_source_color(cr, barLevelActiveColor);
         cr.fillPreserve();
         Clutter.cairo_set_source_color(cr, barLevelActiveBorderColor);
         cr.setLineWidth(barLevelBorderWidth);
@@ -143,17 +144,19 @@ var BarLevel = class {
         }
 
         /* end progress bar arc */
-        if (this._value <= this._overdriveStart)
-            Clutter.cairo_set_source_color(cr, barLevelActiveColor);
-        else
-            Clutter.cairo_set_source_color(cr, barLevelOverdriveColor);
-        cr.arc(endX, height / 2, barLevelBorderRadius, TAU * 3 / 4, TAU * 1 / 4);
-        cr.lineTo(Math.floor(endX), (height + barLevelHeight) / 2);
-        cr.lineTo(Math.floor(endX), (height - barLevelHeight) / 2);
-        cr.lineTo(endX, (height - barLevelHeight) / 2);
-        cr.fillPreserve();
-        cr.setLineWidth(barLevelBorderWidth);
-        cr.stroke();
+        if (this._value > 0) {
+          if (this._value <= this._overdriveStart)
+              Clutter.cairo_set_source_color(cr, barLevelActiveColor);
+          else
+              Clutter.cairo_set_source_color(cr, barLevelOverdriveColor);
+          cr.arc(endX, height / 2, barLevelBorderRadius, TAU * 3 / 4, TAU * 1 / 4);
+          cr.lineTo(Math.floor(endX), (height + barLevelHeight) / 2);
+          cr.lineTo(Math.floor(endX), (height - barLevelHeight) / 2);
+          cr.lineTo(endX, (height - barLevelHeight) / 2);
+          cr.fillPreserve();
+          cr.setLineWidth(barLevelBorderWidth);
+          cr.stroke();
+        }
 
         /* draw overdrive separator */
         if (overdriveActive) {